package com.wing.platform.cabinet.model.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;

/**
 * 暂存柜产品库存
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("cab_storage_inventory_product")
public class StorageInventoryProduct extends BaseEntity<StorageInventoryProduct> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum BusinessType implements IEnum<Integer> {

        /**
         * 暂存
         */
        temp(1,"暂存"),
        /**
         * 维修
         */
        repair(2,"维修"),
        /**
         * 回收
         */
        recycle(3,"回收");

        private int code;
        private String desc;

        BusinessType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static BusinessType jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (BusinessType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 柜子id
     */
    private Long cabId;

    /**
     * sku id
     */
    private Long skuId;

    /**
     * 库存数量
     */
    private Integer quantity;

    /**
     * 企业id
     */
    private Long companyId;

    /**
     * 货道id
     */
    private Integer spaceId;

    /**
     * (0正常，1告警)
     */
    private Long status;

    /**
     * 货道编号
     */
    private String spaceCode;

    /**
     * 柜子编号
     */
    private String cabCode;

    /**
     * sku 编号
     */
    private String skuCode;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private BusinessType businessType;

    /**
     * 企业编码
     */
    private String enterpriseCode;

}
